<template>
    <el-dialog v-model="visible" title="文件分享" width="20%" draggable>
        <el-divider content-position="left"></el-divider>
        <div>
            <el-row>
                <el-col :span="8">
                    <label for="shareUserPhoneNumID">目标用户电话号码</label>
                </el-col>
                <el-col :span="16">
                    <el-input v-model="shareUserPhoneNum" autofocus size="mini" id="shareUserPhoneNumID">
                    </el-input>
                </el-col>
            </el-row>

            <el-row>
                <el-checkbox-group v-model="checkList">
                    <el-checkbox label="只读" />
                    <el-checkbox label="修改" />
                    <el-checkbox label="二次分享" />
                </el-checkbox-group>
            </el-row>

            <div class="block">
                <span class="demonstration">过期时间</span>
                <el-date-picker v-model="expireTime" type="date" placeholder="Pick a day" :disabled-date="disabledDate"
                    :shortcuts="shortcuts" :size="size" />
            </div>

        </div>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogVisible = false">取消</el-button>
                <el-button type="primary" @click="onConfirm">确定</el-button>
            </span>
        </template>
    </el-dialog>
</template>
      
<script  setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus';
// import axios from 'axios';
import { useStore } from 'vuex';
const store = useStore();

const visible = ref(false)
const shareUserPhoneNum = ref("13631218234")
const checkList = ref(['只读', '修改'])
const expireTime = ref('')

const onConfirm = () => {
    console.log("share dlg show--------------:");

    let data = {
        gid: window.gstore.state.curentFile["uuid"],
        owneruid: store.state.uid,
        phoneNum: shareUserPhoneNum.value
    };


    if (shareUserPhoneNum.value.length < 11) {
        ElMessage('号码不正确');
        return;
    }
    post2Share(data);
    visible.value = false;
}


var post2Share = function (data) {
    console.log("store login******************");
    var url = "api/share/shareGraph";
    axios.post(url, data).then(res => {
        console.log(res.data);
        let ret = res.data;
        if (ret == "success") {
            ElMessage('分享成功');
        }
        else {
            ElMessage('分享失败');
        }
    }).catch(function (error) {
        console.log(error);
        ElMessage('分享失败');
    })
}


defineExpose({
    visible
});

</script>
    
<style></style>
      